package backstage.app.controller;

 

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import backstage.app.respont.RespontDateJson;
import backstage.app.service.impl.util.AdminSysUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("${spring.application.name}/adminsys/api")
@Api("管理员-控制器")
public class AdminSysController {
	
	 
	
	@Autowired
	private AdminSysUtils adminSysUtils;
	
	@GetMapping("/login")
	@ApiOperation("管理员登录")
	@ApiImplicitParams({
		@ApiImplicitParam(value="userName用户名登录"),
		@ApiImplicitParam(value="passWord用户密码登录")
	})
	public RespontDateJson<?>login(
			@RequestParam(value="userName",required = true)String userName,
			@RequestParam(value="passWord",required = true)String passWord){
		
		 return adminSysUtils.login(userName, passWord);
	}
	
	
	@GetMapping("/list")
	@ApiOperation("查询集合")
	public RespontDateJson<?> list(@RequestParam(value="page",required = false,defaultValue = "0")Integer page,
			@RequestParam(value="limit",required = false,defaultValue = "20")Integer limit){
		 
		return adminSysUtils.list(page, limit);
	}
	
	
	
	@PostMapping("/insert")
	@ApiOperation("添加管理员")
	@ApiImplicitParams({
		@ApiImplicitParam(value="userName用户名登录"),
		@ApiImplicitParam(value="passWord用户密码登录")
	})
	public RespontDateJson<?>insert(
			@RequestParam(value="userName",required = true)String userName,
			@RequestParam(value="passWord",required = true)String passWord){
		 return adminSysUtils.inser(userName, passWord);
	}
	
	
	@PostMapping("/update")
	@ApiOperation("修改管理员账号")
	@ApiImplicitParams({
		@ApiImplicitParam(value="userName用户名登录"),
		@ApiImplicitParam(value="passWord用户密码登录")
	})
	public RespontDateJson<?>update(
			@RequestParam(value="aid",required = true)Integer aid,
			@RequestParam(value="userName",required = true)String userName,
			@RequestParam(value="passWord",required = true)String passWord){
		 return adminSysUtils.update(aid,userName, passWord);
	}
	
	@PostMapping("/updateStauts")
	@ApiOperation("修改管理员账号状态")
	@ApiImplicitParams({
		@ApiImplicitParam(value="aid "),
		@ApiImplicitParam(value="token ")
	})
	public RespontDateJson<?>updateStauts(
			@RequestParam(value="aid",required = true)Integer aid,
			@RequestParam(value="token",required = true)String  token
			 ){
		 return adminSysUtils.updateStauts(aid,token);
	}
	
	
	@PostMapping("/delete")
	@ApiOperation("删除管理员账号")
	@ApiImplicitParams({
		@ApiImplicitParam(value="aid用户名登录")
		 
	})
	public RespontDateJson<?>delete(
			@RequestParam(value="aid",required = true)Integer aid,
			@RequestParam(value="token",required = true)String  token
			 ){
			return adminSysUtils.delete(aid, token) ;
	}
}
